﻿using System;
using System.Web;
using System.Web.Security;
using VotanetWebSite.Classes;

namespace VotanetWebSite
{
    public partial class Logout : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FormsAuthentication.SignOut();
            Session.Clear();
            Session.Abandon();
            //Session.RemoveAll();
            //HttpCookie cookie = FormsAuthentication.GetAuthCookie(FormsAuthentication.FormsCookieName.ToString(), false);
            //cookie.Expires = DateTime.Now.AddDays(-1);
            //Response.AppendCookie(cookie);
            ShowLogoutMessage(Context.Items["message"] as string);

        }

        private void ShowLogoutMessage(string codigo)
        {
            switch (codigo)
            {
                case "1":
                    Messages.Show(Page, Messages.VOTE_ENTERED, "../Inicio.aspx");
                    break;
                case "2":
                    Messages.Show(Page, Messages.NO_VOTE_ENTERED, "../Inicio.aspx");
                    break;
                default:
                    Response.RedirectPermanent("~/Inicio.aspx");
                    break;
            }
        }
    }
}